//第一种获取target值的方式，通过vue中的响应式对象可使用toRaw()方法获取原始对象
export function sayHello(e){
  console.log('--common-sayhello--called--',e);
  console.log(e.getValue());
  console.log(e.$parent.$parent);

  
  // console.log('this.getFormRef().getTopFormRef():',e.getFormRef().getTopFormRef());

  // console.log('getParentFormRef:',e.getParentFormRef());

  // if(e.$parent.$parent.hasOwnProperty('addEC')){
  //   console.log("common.js:",e.$parent.$parent.getFormData());
  // }

  // console.log(e.$parent.$parent.getFormData());// 找出来根组件

  // let _this = e;
  // _this.getFormData().then(formData => {
  //   alert( JSON.stringify(formData) )
  // }).catch(error => {
  //   _this.$message.error(error)
  // })
}

export function custEventHandle(e,ctx){
  let newEl = {"key":66978,"type":"input","icon":"text-field","formItemFlag":true,"options":{"name":"","label":"","labelAlign":"","type":"text","defaultValue":"","placeholder":"","columnWidth":"200px","size":"","labelWidth":null,"labelHidden":false,"readonly":false,"disabled":false,"hidden":false,"clearable":true,"showPassword":false,"required":false,"requiredHint":"","validation":"","validationHint":"","customClass":"","labelIconClass":null,"labelIconPosition":"rear","labelTooltip":null,"minLength":null,"maxLength":null,"showWordLimit":false,"prefixIcon":"","suffixIcon":"","appendButton":false,"appendButtonDisabled":false,"buttonIcon":"custom-search","onCreated":"","onMounted":"","onInput":"","onChange":"","onFocus":"","onBlur":"","onValidate":"","onAppendButtonClick":"","fileType":""},"displayName":"单行输入"};
  console.log('--custEventHandle--',e);
  console.log('ctx:',ctx);
  
  let _this = ctx;
  let elInput = _this.designer.copyNewFieldWidget(newEl);
  _this.designer.widgetList.push(elInput);

  console.log(_this.designer.widgetList);

  let newWidget  = _this.designer.widgetList[ _this.designer.widgetList.length+1];
  console.log('--this.designer.widgetList--',_this.designer.widgetList);
  console.log('--add new widget--',newWidget);

  _this.designer.setSelected(newWidget);
  _this.designer.emitHistoryChange();

  // console.log('--custEventHandle--',e.getTopFormRef());
  // console.log('--custEventHandle-2-',e.$parent.$parent);
  // let {ctx} = e.$parent.$parent;
  // let {ctx} = getCurrentInstance();

  // let _this = e.$parent.$parent;

  // console.log(e.getFormRef().getTopFormRef());
  // console.log(e.getTopFormRef());
  // e.designer.handleEvent()

  // _this.designer.widgetList.push(_this.designer.widgetList[_this.designer.widgetList.length-1]);
  // const newIndex = _this.designer.widgetList.length+1;
  

  // console.log('--_this.designer--',_this.designer);
  // let newWidget  = _this.designer.widgetList[_this.designer.widgetList.length+1];
  // console.log('--add new widget--',newWidget);
  // _this.designer.setSelected( newWidget);
  // _this.designer.emitHistoryChange();
}